
const {
    updataConfigs,
    getconfigs,
    addview
} = require("../serve/config.js")
const Response = require("../util/respanse.js")
const updataconfig = async (req, res) => {
    try {
        let { bkimg, name, sign, notice } = req.body;
        let resss = await updataConfigs({ bkimg, name, sign, notice });
        if (resss.code) {
            Response.successresponse(res, {
                code: 200,
                message: "修改成功"
            })
        } else {
            Response.errorresponse(res, {
                code: 400,
                msg: "修改失败",
            })
        }
    } catch (error) {
        console.log(error);
        Response.errorresponse(res, {
            code: 500,
            msg: "出错了",
        })
    }
}
const getconfig = async (req, res) => {
    try {
        let resss = await getconfigs();
        if (resss.code) {
            Response.successresponse(res, {
                code: 200,
                data: {
                    data: resss.data,
                    user: resss.user
                },
                message: "查询成功"
            })
        } else {
            Response.errorresponse(res, {
                code: 400,
                msg: "查询失败",
            })
        }
    } catch (error) {
        console.log(error);
        Response.errorresponse(res, {
            code: 500,
            msg: "出错了",
        })
    }
}
const addconfigview = async (req, res) => {
    try {
        let resss = await addview();
        if (resss.code) {
            Response.successresponse(res, {
                code: 200,
                message: "添加成功"
            })
        } else {
            Response.errorresponse(res, {
                code: 400,
                msg: "查询失败",
            })
        }
    } catch (error) {
        console.log(error);
        Response.errorresponse(res, {
            code: 500,
            msg: "出错了",
        })
    }
}
module.exports = {
    updataconfig,
    getconfig,
    addconfigview
}